package com.bicon.bdata_service_search.es.common.result;

/**
 * 描述:
 *
 * @author zhaoyu
 * @email zhaoyu@vv.cc
 * @create 2018-09-11 11:49
 */
public class ResultUtil {
    /**
     * 请求成功返回
     * @param object
     * @return
     */
    public static Result<Object> success(Object object){
        Result<Object> result=new Result<>();
        result.setCode(ResultEnum.SUCCESS.getValue());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }
    public static Result<Object> success(){
        return success(null);
    }

    public static Result error(Integer code,String resultResult){
        Result result=new Result();
        result.setCode(code);
        result.setMsg(resultResult);
        return result;
    }

    public static Result resultWithData(ResultEnum resultEnum,Object object){
        Result result=new Result();
        result.setCode(resultEnum.getValue());
        result.setMsg(resultEnum.getMsg());
        result.setData(object);
        return result;
    }
    public static Result error(ResultEnum resultEnum){
        Result result=new Result();
        result.setCode(resultEnum.getValue());
        result.setMsg(resultEnum.getMsg());
        return result;
    }
}